/*
 * Copyright (c) 2002-2004, xRhino, Inc.
 *
 * This library is free software; you can redistribute and/or modify
 * it under the terms of the dual license distributed with this source
 * package (a combined Trolltech QPL/GPL-compatible license)
 *
 * Under this dual license scheme, a separate license is available for use of 
 * this code with a proprietary (closed) system. For more information on the 
 * license, please see the LICENSE file distributed with this source package.
 */
#ifndef SUGELEMENT_H
#define SUGELEMENT_H

#include <map>
#include <string>
#include "SugTypes.h"
#include "SugTransform.h"
#include "SugNode.h"

using namespace std;

/**
 * SugElement is really the current heart of libsugar.  The parser will output
 * a vector of SugElements.  These SugElements are not of type SugElement 
 * but are of one of a derived class, so you can think of SugElement as 
 * the cookie cutter parent class that they all conform to.
 */
class SugElement: public SugNode
{
 protected:
   /**
    * This is the element type identifier, this is how we know what to cast 
    * our element as (see above).
    */
   SugTypes::ElementType mElementType;

   /**
    * A map containing all the attributes of this element. It is a
    * string to string mapping.
    */
   map<string, string> mAttributes;

 public:

   /**
    * Gets the specified attribute's value in string format.
    *
    * @param attrName The name of the attribute we are getting the value for.
    * @return The attribute's value in string format. NULL if the
    *         attribute doesn't exist in the element.
    */
   const char* getStringAttribute(char* attrName);
   
   /**
    * Gets the specified attribute's value in integer format.
    *
    * @param attrName The name of the attribute we are getting the value for.
    * @param attrValue The value of the attribute.
    * @return Boolean value indicating whether or not the attribute
    *         exists in this element.
    */
   bool getIntegerAttribute(char* attrName, int& attrValue);

   /**
    * Gets the specified attribute's value in float format.
    *
    * @param attrName The name of the attribute we are getting the value for.
    * @param attrValue The value of the attribute.
    * @return Boolean value indicating whether or not the attribute
    *         exists in this element.
    */
   bool getFloatAttribute(char* attrName, float& attrValue);
   
   /**
    * Gets the specified attribute's value in color format.
    *
    * @param attrName The name of the attribute we are getting the value for.
    * @param attrValue The value of the attribute.
    * @return Boolean value indicating whether or not the attribute
    *         exists in this element.
    */
   bool getColorAttribute(char* attrName, SugColor& attrValue);

   /**
    * Gets the specified attribute's value in point list format.
    *
    * @param attrName The name of the attribute we are getting the value for.
    * @param attrValue The value of the attribute.
    * @return Boolean value indicating whether or not the attribute
    *         exists in this element.
    */
   bool getPointListAttribute(char* attrName, vector<SugPoint>& attrValue);

   /**
    * Gets the "transform" attribute's value in transform list format.
    *
    * @param attrValue The value of the attribute.
    * @return Boolean value indicating whether or not the attribute
    *         exists in this element.
    */
   bool getTransformListAttribute(vector<SugTransform>& attrValue);

   /**
    * Returns the id of this element.
    *
    * @return The id string if it exists, NULL otherwise.
    */
   const char* getId();
   
   /**
    * returns the mElementType, this is later used for casting.
    */
   SugTypes::ElementType getElementType();

   /**
    * sets the mElementType of this class.
    */
   void setElementType(SugTypes::ElementType newType);

   /**
    * Adds an attribute and it's corresponding value to the attribute
    * map.
    */
   void addAttribute(char* name, char* value);

   /**
    * Debug function that prints the names and values of all
    * attributes.
    */
   void printAttributes();
   
   /**
    * The class constructor
    */
   SugElement();

   /**
    * The class destructor
    */
   ~SugElement();

};

#endif
